home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / architecture / sparc / asm_linkage.h < prev    next >
Text File  |  1994-09-30  |  5KB  |  226 lines

  1. /*    @(#)asm_linkage.h 1.11 91/05/22 SMI    */
  2.  
  3. /*
  4.  * Copyright (c) 1987 by Sun Microsystems, Inc.
  5.  */
  6.  
  7. /*
  8.  * A stack frame looks like:
  9.  *
  10.  * %fp->|                |
  11.  *    |-------------------------------|
  12.  *    |  Locals, temps, saved floats    |
  13.  *    |-------------------------------|
  14.  *    |  outgoing parameters past 6    |
  15.  *    |-------------------------------|-\
  16.  *    |  6 words for callee to dump    | |
  17.  *    |  register arguments        | |
  18.  *    |-------------------------------|  > minimum stack frame
  19.  *    |  One word struct-ret address    | |
  20.  *    |-------------------------------| |
  21.  *    |  16 words to save IN and    | |
  22.  * %sp->|  LOCAL register on overflow    | |
  23.  *    |-------------------------------|-/
  24.  */
  25.  
  26. #ifndef _sparc_asm_linkage_h
  27. #define _sparc_asm_linkage_h
  28.  
  29. #import    <architecture/sparc/reg.h>
  30.  
  31.  
  32. /*
  33.  * Constants defining a stack frame.
  34.  */
  35. #define WINDOWSIZE    (16*4)        /* size of window save area */
  36. #define ARGPUSHSIZE    (6*4)        /* size of arg dump area */
  37. #define ARGPUSH        (WINDOWSIZE+4)    /* arg dump area offset */
  38. #define MINFRAME    (WINDOWSIZE+ARGPUSHSIZE+4) /* min frame */
  39.  
  40. /*
  41.  * Stack alignment macros.
  42.  */
  43. #define STACK_ALIGN    8
  44. #define SA(X)    (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1))
  45.  
  46.  
  47. /*
  48.  * Profiling causes defintions of the MCOUNT and RTMCOUNT
  49.  * particular to the type.  Note: the nop in the following
  50.  * macros allows them to be used in a delay slot.
  51.  */
  52. #ifdef GPROF
  53.  
  54. #define MCOUNT(x) \
  55.     nop; \
  56.     save    %sp, -SA(MINFRAME), %sp; \
  57.     call    mcount; \
  58.     nop ; \
  59.     restore    ;
  60.  
  61. #define RTMCOUNT(x) \
  62.     nop; \
  63.     save    %sp, -SA(MINFRAME), %sp; \
  64.     call    mcount; \
  65.     nop ; \
  66.     restore    ;
  67.  
  68. #endif GPROF
  69.  
  70.  
  71. #ifdef PROF
  72.  
  73. #define MCOUNT(x) \
  74.     nop; \
  75.     save    %sp, -SA(MINFRAME), %sp; \
  76.     sethi    %hi(L_##x##1), %o0; \
  77.     call    mcount; \
  78.         or      %o0, %lo(L_##x##1), %o0; \
  79.         restore; \
  80.         .comm    L_##x##1,4
  81.  
  82. #define RTMCOUNT(x) \
  83.     nop; \
  84.     save    %sp, -SA(MINFRAME), %sp; \
  85.         sethi    %hi(L##x##1), %o0; \
  86.         call    mcount; \
  87.         or    %o0, %lo(L##x##1), %o0; \
  88.         restore; \
  89.         .comm    L##x##1,4
  90.  
  91. #endif PROF
  92.  
  93. /*
  94.  * if we are not profiling,
  95.  * MCOUNT and RTMCOUNT should be defined to nothing
  96.  */
  97. #if !defined(PROF) && !defined(GPROF)
  98. #define MCOUNT(x)
  99. #define RTMCOUNT(x)
  100. #endif !PROF && !GPROF
  101.  
  102. /*
  103.  * Entry macros for assembler subroutines.
  104.  * NAME prefixes the underscore before a symbol.
  105.  * ENTRY provides a way to insert the calls to mcount for profiling.
  106.  * RTENTRY is similar to the above but provided for run-time routines
  107.  *    whose names should not be prefixed with an underscore.
  108.  */
  109.  
  110. #define    NAME(x) _##x
  111.  
  112. #define ENTRY(x) \
  113.     .global    NAME(x); \
  114.     .align 2 ; \
  115.     NAME(x): MCOUNT(x)
  116.  
  117. #define ENTRY2(x,y) \
  118.     .global    NAME(x), NAME(y); \
  119.     .align 2 ; \
  120.     NAME(x): ; \
  121.     NAME(y): MCOUNT(x)
  122.  
  123. #define RTENTRY(x) \
  124.     .global    x; x: RTMCOUNT(x)
  125.  
  126. /*
  127.  * For additional entry points.
  128.  */
  129. #define ALTENTRY(x) \
  130.     .global NAME(x); \
  131.     .align 2 ; \
  132. NAME(x):
  133.  
  134. #ifdef KERNEL
  135. /*
  136.  * Macros for saving/restoring registers.
  137.  */
  138.  
  139. #define SAVE_GLOBALS(RP) \
  140.     st    %g1, [RP + G1*4]; \
  141.     std    %g2, [RP + G2*4]; \
  142.     std    %g4, [RP + G4*4]; \
  143.     std    %g6, [RP + G6*4]; \
  144.     mov    %y, %g1; \
  145.     st    %g1, [RP + SPARC_Y*4]
  146.  
  147. #define RESTORE_GLOBALS(RP) \
  148.     ld    [RP + SPARC_Y*4], %g1; \
  149.     mov    %g1, %y; \
  150.     ld    [RP + G1*4], %g1; \
  151.     ldd    [RP + G2*4], %g2; \
  152.     ldd    [RP + G4*4], %g4; \
  153.     ldd    [RP + G6*4], %g6;
  154.  
  155. #define SAVE_OUTS(RP) \
  156.     std    %i0, [RP + O0*4]; \
  157.     std    %i2, [RP + O2*4]; \
  158.     std    %i4, [RP + O4*4]; \
  159.     std    %i6, [RP + O6*4]
  160.  
  161. #define RESTORE_OUTS(RP) \
  162.     ldd    [RP + O0*4], %i0; \
  163.     ldd    [RP + O2*4], %i2; \
  164.     ldd    [RP + O4*4], %i4; \
  165.     ldd    [RP + O6*4], %i6;
  166.  
  167. #define SAVE_WINDOW(SBP) \
  168.     std    %l0, [SBP + (0*4)]; \
  169.     std    %l2, [SBP + (2*4)]; \
  170.     std    %l4, [SBP + (4*4)]; \
  171.     std    %l6, [SBP + (6*4)]; \
  172.     std    %i0, [SBP + (8*4)]; \
  173.     std    %i2, [SBP + (10*4)]; \
  174.     std    %i4, [SBP + (12*4)]; \
  175.     std    %i6, [SBP + (14*4)]
  176.  
  177. #define RESTORE_WINDOW(SBP) \
  178.     ldd    [SBP + (0*4)], %l0; \
  179.     ldd    [SBP + (2*4)], %l2; \
  180.     ldd    [SBP + (4*4)], %l4; \
  181.     ldd    [SBP + (6*4)], %l6; \
  182.     ldd    [SBP + (8*4)], %i0; \
  183.     ldd    [SBP + (10*4)], %i2; \
  184.     ldd    [SBP + (12*4)], %i4; \
  185.     ldd    [SBP + (14*4)], %i6;
  186.  
  187. #define STORE_FPREGS(FCP) \
  188.     std    %f0, [FCP + FPCTX_REGS]; \
  189.     std    %f2, [FCP + FPCTX_REGS + 8]; \
  190.     std    %f4, [FCP + FPCTX_REGS + 16]; \
  191.     std    %f6, [FCP + FPCTX_REGS + 24]; \
  192.     std    %f8, [FCP + FPCTX_REGS + 32]; \
  193.     std    %f10, [FCP + FPCTX_REGS + 40]; \
  194.     std    %f12, [FCP + FPCTX_REGS + 48]; \
  195.     std    %f14, [FCP + FPCTX_REGS + 56]; \
  196.     std    %f16, [FCP + FPCTX_REGS + 64]; \
  197.     std    %f18, [FCP + FPCTX_REGS + 72]; \
  198.     std    %f20, [FCP + FPCTX_REGS + 80]; \
  199.     std    %f22, [FCP + FPCTX_REGS + 88]; \
  200.     std    %f24, [FCP + FPCTX_REGS + 96]; \
  201.     std    %f26, [FCP + FPCTX_REGS + 104]; \
  202.     std    %f28, [FCP + FPCTX_REGS + 112]; \
  203.     std    %f30, [FCP + FPCTX_REGS + 120]
  204.  
  205. #define LOAD_FPREGS(FCP) \
  206.     ldd    [FCP + FPCTX_REGS ], %f0; \
  207.     ldd    [FCP + FPCTX_REGS + 8], %f2; \
  208.     ldd    [FCP + FPCTX_REGS + 16], %f4; \
  209.     ldd    [FCP + FPCTX_REGS + 24], %f6; \
  210.     ldd    [FCP + FPCTX_REGS + 32], %f8; \
  211.     ldd    [FCP + FPCTX_REGS + 40], %f10; \
  212.     ldd    [FCP + FPCTX_REGS + 48], %f12; \
  213.     ldd    [FCP + FPCTX_REGS + 56], %f14; \
  214.     ldd    [FCP + FPCTX_REGS + 64], %f16; \
  215.     ldd    [FCP + FPCTX_REGS + 72], %f18; \
  216.     ldd    [FCP + FPCTX_REGS + 80], %f20; \
  217.     ldd    [FCP + FPCTX_REGS + 88], %f22; \
  218.     ldd    [FCP + FPCTX_REGS + 96], %f24; \
  219.     ldd    [FCP + FPCTX_REGS + 104], %f26; \
  220.     ldd    [FCP + FPCTX_REGS + 112], %f28; \
  221.     ldd    [FCP + FPCTX_REGS + 120], %f30; \
  222.  
  223. #endif KERNEL
  224.  
  225. #endif /*!_sparc_asm_linkage_h*/
  226.